package com.ruoyi.common.service.impl;

import com.ruoyi.common.domain.Type_SegVo;
import com.ruoyi.common.service.IndexService;
import com.ruoyi.people.student.mapper.StudentMapper;
import com.ruoyi.people.teacher.mapper.TeacherMapper;
import com.ruoyi.prevention.segregater.mapper.SegregaterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 数据可视化页面
 * @author wad
 * @date 2022/4/30 14:52
 * @project RuoYi-YiQing
 **/
@Service
public class IndexServiceImpl implements IndexService {

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private SegregaterMapper segregaterMapper;


    /**
     * 第一个图的实现
     * @return
     */
    @Override
    public List<Integer> OneCharts(){
        List<Integer> list=new ArrayList<>();
        List<Integer> studentList = studentMapper.count3();
        List<Integer> teacherList = teacherMapper.count3();
        for (int i = 0; i < studentList.size(); i++) {
            list.add(studentList.get(i) + teacherList.get(i));
        }
        return list;
    }

    /**
     * 第二个图
     * @return
     */
    @Override
    public List<Integer> TwoCharts(){
        List<Integer> list=new ArrayList<>();
        List<Integer> studentList = studentMapper.count4();
        List<Integer> teacherList = teacherMapper.count4();
        for (int i = 0; i < studentList.size(); i++) {
            list.add(studentList.get(i) + teacherList.get(i));
        }
        return list;
    }

    /**
     * 第三个图
     * @return
     */
    @Override
    public List<Integer> threeCharts() {
        return segregaterMapper.count5();
    }

    /**
     * 第五个图
     * @return
     */
    @Override
    public List<Integer> fiveChart1() {
        List<Integer> list=new ArrayList<>();
        List<Integer> studentList = studentMapper.count6();
        List<Integer> teacherList = teacherMapper.count6();
        for (int i=0;i<studentList.size();i++){
            list.add(studentList.get(i)+teacherList.get(i));
        }
        return list;
    }

    @Override
    public List<Integer> fiveChart2() {
        List<Integer> list=new ArrayList<>();
        List<Integer> studentList = studentMapper.count7();
        List<Integer> teacherList = teacherMapper.count7();
        for (int i=0;i<studentList.size();i++){
            list.add(studentList.get(i)+teacherList.get(i));
        }
        return list;
    }

    @Override
    public List<Integer> fiveChart3() {
        List<Integer> list=new ArrayList<>();
        List<Integer> studentList = studentMapper.count8();
        List<Integer> teacherList = teacherMapper.count8();
        for (int i=0;i<studentList.size();i++){
            list.add(studentList.get(i)+teacherList.get(i));
        }
        return list;
    }

    @Override
    public Type_SegVo fourChart1() {
        Type_SegVo typeSegVo=new Type_SegVo();
        typeSegVo.setName("学生");
        typeSegVo.setValue(segregaterMapper.count6());
        return typeSegVo;
    }

    @Override
    public Type_SegVo fourChart2() {
        Type_SegVo typeSegVo=new Type_SegVo();
        typeSegVo.setName("教师");
        typeSegVo.setValue(segregaterMapper.count7());
        return typeSegVo;
    }

    @Override
    public Type_SegVo fourChart3() {
        Type_SegVo typeSegVo=new Type_SegVo();
        typeSegVo.setName("其他人员");
        typeSegVo.setValue(segregaterMapper.count8());
        return typeSegVo;
    }
}
